package org.jsbd.boss.task;

import java.text.SimpleDateFormat;

import javax.annotation.Resource;

import org.jsbd.boss.service.ISimulatorUVService;
import org.jsbd.boss.util.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 咪咕apk下载
 * 
 * @author zbh
 * 
 */
public class SimulatorUVTask implements Runnable {

	@Resource
	private ISimulatorUVService simulatorUVService; 
	// 用于判断定时任务是否开启
	private final static String QUARTZ_FLAG_ON = "on";
	// 定时任务开关：默认为off
	private String quartzFlag = PropertiesUtil.getValue("simulator_UV_flag", "off");

	public static final Logger LOGGER = LoggerFactory.getLogger(SimulatorUVTask.class);

	public void start() {
		Thread t = new Thread(this);
		t.start();
	}

	@Override
	public void run() {
		// 只有当定时任务为on的时候才会去执行业务逻辑
		if (QUARTZ_FLAG_ON.equalsIgnoreCase(quartzFlag)) {
			while (true) {
				try {
					// logger.info("今天已经执行了+total+");
					Thread.sleep(10000);
				} catch (InterruptedException e) {
					LOGGER.error("", e);
				}
				try {
					simulatorUVService.simulatorUV();
				} catch (Exception e) {
					LOGGER.error("", e);
				}
				
			}
		}
	}

	public String getQuartzFlag() {
		return quartzFlag;
	}

	public void setQuartzFlag(String quartzFlag) {
		this.quartzFlag = quartzFlag;
	}

	public static String getQuartzFlagOn() {
		return QUARTZ_FLAG_ON;
	}

}
